using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Trippy.CollidableGameComponents;
using Trippy.CollidableGameComponents.Objects;
using Trippy.Levels;

namespace Trippy.Effects
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class BlockWave : Effect
    {
        public BlockWave(Level level) : base(level)
        {
        }

        public BlockWave(Level level, IEnumerable<CollidableGameComponent> components)
            : base(level, components)
        {
        }

        //bool initialized = false;

        /// <summary>
        /// Advances the effect one tick.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
           /* if (!initialized)
            {
                SetInitialPhysics(gameTime);
                initialized = true;
            } */
            for (int i = 0; i < Components.Count; i ++)
            {
                Components[i].Velocity = new Vector2(0, 70.0f * (float)Math.Cos(.5f * gameTime.TotalGameTime.TotalSeconds + i / 4.0f));
            }
            base.Update(gameTime);
        }

        /*
        public void SetInitialPhysics(GameTime gameTime)
        {
            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].Position = new Vector2(initialPositions[i].X, initialPositions[i].Y + 400.0f * (float)Math.Sin(.3 * gameTime.TotalGameTime.TotalSeconds + i / 4.0f));
                // Components[i].Velocity = new Vector2(initialPositions[i].X, 120.0f * (float)Math.Sin(.3 * gameTime.TotalGameTime.TotalSeconds + i / 4.0f));
            }
        }
         */
    }
}
